package tianxing

import (
	"encoding/json"
	ms "gin_template/core/request"

	"go.uber.org/zap"
)

type Config struct {
	Key string
	Url string
}

type Common struct {
	Code int    `json:"code"`
	Msg  string `json:"msg"`
}

type Result struct {
	Common
	Newslist []Value `json:"newslist"`
}

type Value struct {
	Content string `json:"content"`
}

func RequestSayLove(config interface{}) string {
	conf := config.(*Config)
	result := &Result{}
	res := ms.RequestGet(conf.Url + "/saylove/index?key=" + conf.Key)
	err := json.Unmarshal(res, &result)
	if err != nil {
		zap.L().Info("RequestSayLove序列化失败", zap.Error(err))
	}
	if result.Code == 150 {
		return "今天情话机器人卡壳啦，请充值让我修复它吧，hhh"
	}
	var info = result.Newslist[0].Content
	return info

}
